package cn.flant.log.adapter;

public class ComLogAdapter extends LogAdapter {
	private org.apache.commons.logging.Log log = null;

	protected ComLogAdapter(String name) {
		super(name);
		log = org.apache.commons.logging.LogFactory.getLog(name);
		if (log == null) {
			throw new IllegalStateException("Common logging is not available");
		}
	}

	@Override
	public void debug(Object msg) {
		if (DEBUG < level) {
			return;
		}
		log.debug(msg);

	}

	@Override
	public void debug(Object msg, Throwable t) {
		if (DEBUG < level) {
			return;
		}
		log.debug(msg, t);
	}

	@Override
	public void error(Object msg) {
		if (ERROR < level) {
			return;
		}
		log.error(msg);

	}

	@Override
	public void error(Object msg, Throwable t) {
		if (ERROR < level) {
			return;
		}
		log.debug(msg, t);

	}

	@Override
	public void fatal(Object msg) {
		if (FATAL < level) {
			return;
		}
		log.fatal(msg);
	}

	@Override
	public void fatal(Object msg, Throwable t) {
		if (FATAL < level) {
			return;
		}
		log.fatal(msg, t);

	}

	@Override
	public void info(Object msg) {
		if (INFO < level) {
			return;
		}
		log.info(msg);

	}

	@Override
	public void info(Object msg, Throwable t) {
		if (INFO < level) {
			return;
		}
		log.info(msg, t);

	}

	@Override
	public void warn(Object msg) {
		if (WARN < level) {
			return;
		}
		log.warn(msg);

	}

	@Override
	public void warn(Object msg, Throwable t) {
		if (WARN < level) {
			return;
		}
		log.warn(msg, t);
	}

}
